package com.bluediesel.utils.managers.scenemanager.commands
{
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class TimedCommand extends Command
	{
		private var _timer:Timer;
		
		public function TimedCommand(delay:Number=0)
		{
			_timer = new Timer(int(1000 * delay), 1);
			_timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
			//super(null);
		}
		
		private function onTimerComplete(e:TimerEvent):void {
			executeAll();
		}
		
		/**
		 * Starts the command. 
		 * Waits for the timer to complete and calls the execute() method.
		 * This method can be used directly as an event listener.
		 */
		override public function start(e:Event = null):void {
			_timer.start();
		}
	}	
}